<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>WriteData</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<font face="Arial" size="2"><p align="center"><b><font size="4">WriteData()</font></b></p>
<p><b>语法</b></p><blockquote>

Result = <font color="#006666"><b>WriteData</b></font>(#File, *MemoryBuffer, Length)</blockquote>

</blockquote>
<b>概要</b><br><blockquote>



Write the content of the specified memory buffer to a file. 

 

</blockquote><p><b>参数</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>#File</i></td>
<td width="90%"> 
 
The file to write to. 

 

</td></tr>
<tr><td><i>*MemoryBuffer</i></td>
<td> 
 
The memory address of the data to write to the file. 

 

</td></tr>
<tr><td><i>Length</i></td>
<td> 
 
The number of bytes to write to the file. 

 

</td></tr>
</table>
</blockquote><p><b>返回值</b></p><blockquote>



Returns the number of bytes actually written to the file. 
If there is an error, the return-value is zero. 

 

</blockquote><p><b>Remarks</b></p><blockquote>



Because of <a href="filebufferssize.html">file buffering</a>, this function may return successful even if there is not enough 
space left on the output device for the write operation. 
The file must be opened using a write-capable function (i.e. not with <a href="readfile.html">ReadFile()</a>). 

 

</blockquote><p><b>示例</b></p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">
  *MemoryID =<font color="#006666"> AllocateMemory</font>(1000)       <font color="#006666">; allocating a memory block</font>
  <b><font color="#006666">If</font></b> *MemoryID
<font color="#006666">    PokeS</font>(*MemoryID, "Store this string in the memory area")   <font color="#006666">; we write a string into the memory block</font>
  <b><font color="#006666">EndIf</font></b>
  <b><font color="#006666">If</font></b> <font color="#006666">CreateFile</font>(0, "Text.txt")           <font color="#006666">; we create a new text file...</font>
<font color="#006666">    WriteData</font>(0, *MemoryID, 10)          <font color="#006666">; write the first 10 chars from the memory block into the file</font>
<font color="#006666">    CloseFile</font>(0)                         <font color="#006666">; close the previously opened file and so store the written data</font>
  <b><font color="#006666">Else</font></b>
    <b><font color="#006666">Debug</font></b> "may not create the file!"
  <b><font color="#006666">EndIf</font></b>

</font></pre>

</blockquote><p><b>参阅</b></p><blockquote>

<a href="readdata.html">ReadData()</a>, <a href="createfile.html">CreateFile()</a>, <a href="openfile.html">OpenFile()</a> 

</Blockquote><p><b>已支持操作系统 </b><Blockquote>所有</Blockquote></p><center>&lt;- <a href=writecharacter.html>WriteCharacter()</a> - <a href=index.html>File Index</a> - <a href=writedouble.html>WriteDouble()</a> -&gt;



</body></html>